@extends('welcome')
<link rel="stylesheet" href="/Home/User/css/safe/ms-style.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/personal_member.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/Snaddress.min.css" />
<link rel="stylesheet" href="/Home/login/css/landreg.css" />
<!-- 收藏列表部分样式 -->
<link rel="stylesheet" href="/Home/collect/user.css" />
<link rel="stylesheet" href="/Home/collect/userleft.css" />
<link rel="stylesheet" href="/Home/collect/asyncbox.css" />
<!-- 表格样式 -->
<link rel="stylesheet" href="/Home/address/css.css" />
<link rel="stylesheet" href="/Home/address/sui.css" />
<link rel="stylesheet" href="/Home/address/common.min.css" />
<!--导入地区联动插件-->
<script type="text/javascript" src="/Home/UserEdit/jquery.js"></script>
<script type="text/javascript" src="/Home/UserEdit/area.js"></script>
<script type="text/javascript" src="/Home/UserEdit/location.js"></script>
@section('titletitle','收藏列表--优品惠')
@section('zhong_content')
  <br/>
  <!-- 用户中心开始 -->
  <div id="ms-center" class="personal-member">
    <div class="cont">
      <div class="cont-side">
        <div class="side-neck">
          <i></i>
        </div>
        <div class="ms-side">
          <article class="side-menu side-menu-off">
            <dl class="side-menu-tree">
              <dt>订单管理</dt>
              <dd><a  href="{{url('home/user/index')}}" target="_self"><span class="active"></span>订单中心</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>账户管理</dt>
              <dd><a href="{{url('home/user/edit')}}" target="_self"><span class="active"></span>我的资料</a></dd>
              <dd><a href="{{url('home/user/password')}}" target="_self"><span class="active"></span>密码修改</a></dd>
              <dd><a href="{{url('home/user/address')}}" target="_self"><span></span>地址管理</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>收藏管理</dt>
              <dd><a href="{{url('home/collect/index')}}" target="_self" style="color:#f70"><span class="active"></span>收藏列表</a></dd>
            </dl>
            <a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
          </article>
        </div>
      </div>
      <div class="cont-main">
        <div class="main-wrap mt15">
        @if(session('error'))
          {{session('error')}}
        @endif

        @if (count($errors) > 0)
          <div class="">
            <ul>
              @foreach ($errors->all() as $error)
                <div class="cont-main alert alert-danger alert-dismissable" style="width:400px">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                  <li>{{ $error }}</li>
                </div>
              @endforeach
            </ul>
          </div>
        @endif

        @if(session('success'))
        <div class="cont-main alert alert-success alert-dismissable" style="width:400px">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h5> {{session('success')}} </h5>
        </div>
        @endif
        @if(session('error'))
        <div class="cont-main alert alert-danger alert-dismissable" style="width:400px">
           <h5> {{session('error')}} </h5>
        </div>
        @endif
          <!-- 收藏物品列表 start -->
          <h3><strong style=" font-size: 14px;">收藏商品</strong></h3>
          <div class="yhq_con">
            <div class="sc_tit">
              <dl class="yhq_tit clearfix" id="mysc">
                <dd class="active"><a href="/user.php?act=collection_list">全部</a></dd>
              </dl>
              <div class="sc_del">
                <span><input name="chk_all" id="chk_all" type="checkbox">全选</span>
                <span><a href="javascript:;" id="del_all">删除</a></span>
              </div>
            </div>
            <div class="sc_con" id="mysc_Content0" style=" display:block;">
              <dl class="skim_list clearfix">
                @if($ress == 1)
                @foreach ($collects as $k=>$v)
                <dd class="skim_pro">
                  <div class="pic">
                    <a href="/home/list/details/{{$v->goods_id}}"><img src="/uploads/{{$v->pic}}" width="233" height="233"></a>
                    <a href="javascript:;" class="pic_del" style="display: block;">删除</a>
                    <span class="pic_delete" style="display:none">{{$v->id}}</span>
                  </div>
                  <p class="pic_tit">
                    <input name="chk_list" value="76910" type="checkbox">
                    <a href="/home/list/details/{{$v->goods_id}}">{{$v->goods_name}}</a>
                  </p>
                  <p class="pic_price">
                    <span class="newprice">￥<strong>{{$v->price}}</strong></span>
                    <!--<span class="oldprice">￥3980</span>-->
                  </p>
                  <p class="jrgwc"><a href="javascript:;"></a></p>
                </dd>
                @endforeach
                @else
                <h3><strong style=" font-size: 14px;">您还没有收藏任何物品,请前往<a href="/">首页</a>浏览</strong></h3>
                @endif
              </dl>
            </div>
          </div>
          <!-- 收藏物品列表 end -->
        </div>
      </div>
    </div>
  </div>
  <!-- 用户中心结束 -->
@endsection
@section('myjs')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
    //单独删除收藏的商品
    $('.pic_del').click(function(){
      var id = $(this).parents('dd').find('.pic_delete').html();
      // alert(id);
      var dd = $(this);
      //发送ajax
      $.post('/home/collect/delete',{id:id},function(data){
        if(data == 1){
          dd.parents('dd').remove();
          alert('删除成功');
        }else{
          alert('删除失败');
        }
      })
      return false;
    });
    //选择和取消选择全部商品
    var inp = document.getElementsByName('chk_list');
    var chk = document.getElementById('chk_all');
    $('#chk_all').click(function(){
      for (var i = 0; i <  inp.length; i++) {
         inp[i].checked = chk.checked;
      };
    })
    //删除全部商品
    $('#del_all').click(function(){
      var chk = document.getElementById('chk_all');
      // alert(chk.checked);//选中为true,未选中为false
      //如果没有选中
      if(chk.checked == false){
        alert('请选择要删除的商品');
      }else{
        //发送ajax
        $.post('/home/collect/deleteall',function(data){
          if(data == 1){
            $('.skim_list').empty();
            alert('删除成功');
          }else{
            alert('您还没有收藏任何商品');
          }
        })
      }
      return false;
    });
</script>
@show